/*
 * $Id: Transmittable.h,v 1.6 2006-02-08 11:36:16 bacon Exp $
 */

#ifndef _XPP_NET_TRANSMITTABLE_CLASS_
#define _XPP_NET_TRANSMITTABLE_CLASS_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/bas/time.h>

namespace xpp
{
	namespace net
	{

		class Transmittable
		{
		public:
			virtual ~Transmittable () {}
			
			// TODO:...............
			enum {
				OPT_MSG_OOB     = 0x01,
				OPT_MSG_PEEK    = 0x02,
				OPT_DONTROUTE   = 0x04 
			};

			virtual void enableTimeout (xp_time_t t) = 0;
			virtual void disableTimeout () = 0;

			virtual xp_ssize_t send (
				const void* data, xp_size_t size, int flags = 0) = 0;
			virtual xp_ssize_t sendAll (
				const void* data, xp_size_t size, int flags = 0) = 0;

			virtual xp_ssize_t receive (
				void* buf, xp_size_t size, int flags = 0) = 0;
			virtual xp_ssize_t receiveAll (
				void* buf, xp_size_t size, int flags = 0) = 0;

			enum {
				ERR_NONE = 0,
				ERR_GENERAL,
				ERR_MEMORY,
				ERR_CANCELED,
				ERR_TIMEDOUT,
				__NERRCODES__
			};

			virtual int errorCode () const
			{
				return error_code;
			}

		protected:
			int error_code;
		};

	}
}

#endif
